package com.runen.infinitemovement.adapter;


import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.runen.infinitemovement.R;
import com.runen.infinitemovement.model.entity.TopCompanyRecommendEntity;
import com.runen.infinitemovement.tool.CommonUtil;
import com.runen.infinitemovement.tool.GlideUtils;
import com.runen.infinitemovement.widget.imageview.RoundedCornersImage;

/**
 * Create by LiaoDuanHong
 * Create on
 */
public class CheckJoinUsRecommendAdapter extends BaseQuickAdapter<TopCompanyRecommendEntity.DataBean, BaseViewHolder> {
    private Context context;
    private OnClick onClick;

    public CheckJoinUsRecommendAdapter(Context context, OnClick onClick) {
        super(R.layout.item_check_join_us_recommend);
        this.context = context;
        this.onClick = onClick;
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, TopCompanyRecommendEntity.DataBean item) {
        RoundedCornersImage rci_team_logo = baseViewHolder.getView(R.id.rci_team_logo);
        TextView tv_team_name = baseViewHolder.getView(R.id.tv_team_name);
        TextView tv_join = baseViewHolder.getView(R.id.tv_join);
        TextView tv_team_count = baseViewHolder.getView(R.id.tv_team_count);
        TextView tv_completionRate = baseViewHolder.getView(R.id.tv_completionRate);
        GlideUtils.loadImage(context, item.logo, rci_team_logo);
        tv_team_name.setText(item.teamName);
        tv_team_count.setText("团队 " + item.count + " 人");
        tv_completionRate.setText("长征进度 " + CommonUtil.Double2position(item.completionRate * 100) + "%");

        tv_join.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onClick != null) {
                    onClick.join(item.teamId, item.passwordStatus);
                }
            }
        });
    }

    public interface OnClick {
        void join(String companyId, boolean isNeedPassWord);
    }
}
